package com.hospital.pharmacy.controller;

import com.alibaba.fastjson.JSON;
import com.hospital.pharmacy.dao.InventoryMapper;
import com.hospital.pharmacy.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: Hospital
 * @description: 库存
 * @author: 杨曼珍
 * @create: 2019-01-07 15:51
 **/
@Controller
@RequestMapping(value = "/inventory")
public class InventoryController {
    @Autowired
    InventoryService inventoryService;

    @RequestMapping(value = "/all",produces = "application/json;charset=utf-8",method = RequestMethod.GET)
    @ResponseBody
    public String getInventory(){
        return inventoryService.getAllInventory();
    }

    @RequestMapping(value = "/mdcName",produces = "application/json;charset=utf-8",method = RequestMethod.POST)
    @ResponseBody
    public String getInventoryBymdcName(@RequestBody String data){
        String string = JSON.parseObject(data).getString("mdcName");
        return inventoryService.getInventoryByMedName(string);
    }
}
